package algorithm.example;

import java.io.File;

public class DeleteFiles {


    public static void main(String[] args) {
        String path = "D:\\学习视频";

        File file = new File(path);

        for (File f : file.listFiles()) {
            deleteFile(f);
        }
    }

    private static void deleteFile(File f) {
        if (f.isDirectory()){
            File[] files = f.listFiles();
            if (files.length==0){
                f.delete();
            }else{
                for (File file : files) {
                    deleteFile(file);
                }
            }
        }else{
            f.delete();
        }
    }
}
